import React, { Dispatch } from 'react';
import { AssetAcquisitionManageAPI } from '../common/type';
import { FormInstance } from 'antd';

interface AcquisitionTableTypes {
  dataSource: Record<string, any>[]; //表格数据
  loading: boolean; // 加载
  mapList: Record<string, any>;
  materielForm: any; // 选中的材料信息表单
  pagination: Record<string, any>; //分页参数
  otherParams: Record<string, any>; //当前请求参数
  searchList: AssetAcquisitionManageAPI.ISearchList;
  reloadTableData: () => void; // 重置
  [key: string]: any;
}

/**
 * Context 默认值类型
 */
type ManageContextTypes = {
  contractForm: FormInstance | any;
  rightTableProps: AcquisitionTableTypes; //表格数据参数
  curRes: Record<string, any>; // 权限
  acquisitionDispatch: Dispatch<any>; // 派发
  materielList: any; // 选中的材料列表
  contractList: any; // 选中的合同列表
  contractMaterList: any; // 选中合同带出来的物料
  addMatrielList: any;
  purchaseList: any; // 采购申请列表
  contractProcessList: any; // 履行节点
  serverList: any; // 服务list
};

/**
 * useContext
 * @rightTableProps 公共表格所需参数
 * @curRes 权限
 * @acquisitionDispatch reduce 派发器
 */
const INIT_ACQUISITIONMANAGE_CONTEXT: ManageContextTypes = {
  rightTableProps: {
    dataSource: [
      {
        id: '100000000151',
        applyInfo: '领用申请',
        applyFile: '',
        applyState: 0,
        workflowID: '111100000151',
        checkState: '审批中',
        applyStartTime: '2023-12-27',
        applyEndTime: '2023-12-28',
        ownerID: '超级管理员',
      },
      {
        id: '100000000152',
        applyInfo: '2023-04-10-行政部资产领用申请',
        applyFile: '',
        applyState: 1,
        workflowID: '111100000152',
        checkState: '审批通过',
        applyStartTime: '2023-12-27',
        applyEndTime: '2023-12-28',
        ownerID: '资管员',
      },
    ],
    materielForm: {},
    loading: false,
    getAcquisitionTableData: ({}) => {},
    mapList: [],
    pagination: {},
    otherParams: {},
    searchList: [],
    reloadTableData: () => {},
  },
  contractForm: {},
  materielList: [],
  contractList: [],
  contractMaterList: [],
  addMatrielList: [],
  purchaseList: [],
  contractProcessList: [],
  serverList: [],
  curRes: {},
  acquisitionDispatch: () => {},
};

const AcquisitionManageContext = React.createContext(INIT_ACQUISITIONMANAGE_CONTEXT);

export { AcquisitionManageContext };
